package com.nuo.modules.video.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuo.common.utils.InfoUtils;
import com.nuo.common.utils.PageUtils;
import com.nuo.common.utils.Query;
import com.nuo.modules.video.dao.VideoDao;
import com.nuo.modules.video.entity.VideoEntity;
import com.nuo.modules.video.service.VideoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("videoService")
public class VideoServiceImpl extends ServiceImpl<VideoDao, VideoEntity> implements VideoService {

    @Autowired
    InfoUtils<VideoEntity> infoUtils;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String title = (String) params.get("title");

        IPage<VideoEntity> page = this.page(
                new Query<VideoEntity>().getPage(params),
                new LambdaQueryWrapper<VideoEntity>()
                        .like(StringUtils.isNotBlank(title), VideoEntity::getTitle, title)
                        .orderByDesc(VideoEntity::getCreateTime)
        );

        return new PageUtils(page);
    }

}
